//
//  TextAndImgVM.m
//  Demo
//
//  Created by lx on 2018/12/25.
//  Copyright © 2018 mgz. All rights reserved.
//

#import "TextAndImgVM.h"
#import "TextAndImgCell.h"
@interface TextAndImgVM ()
@property (nonatomic,strong)UIColor *object;
@end

@implementation TextAndImgVM
- (instancetype)init
{
    self = [super init];
    if (self) {
        self.inset=UIEdgeInsetsMake(10, 0, 0, 0);
        self.minimumLineSpacing=5;
        self.minimumInteritemSpacing=2;
    }
    return self;
}

- (NSInteger)numberOfItems{
    
    return 1;
}

- (CGSize)sizeForItemAtIndex:(NSInteger)index{
    return  CGSizeMake([[UIScreen mainScreen] bounds].size.width, 100);
}

- (UICollectionViewCell *)cellForItemAtIndex:(NSInteger)index{
    TextAndImgCell *cell = [self.collectionContext dequeueReusableCellOfClass:[TextAndImgCell class] forSectionController:self atIndex:index];
    cell.titleLab.text = @"这是文本加图片";
    cell.img.backgroundColor = self.object;
    return cell;
}

- (void)didUpdateToObject:(NSNumber *)object{
    if (object.integerValue == 2222) {
        self.object = [UIColor greenColor];
    }else if (object.integerValue == 3333){
        self.object = [UIColor blueColor];
    }else{
        self.object = [UIColor yellowColor];
    }
    
}
- (void)didSelectItemAtIndex:(NSInteger)index{
    
    
}
@end
